package com.xyg.product.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.xyg.common.model.DataEntity;

import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name="xyg_product_property")
public class Property extends DataEntity<Property, Long>{
	/**名称*/
	private String name;
	
	/**是否必须*/
	private Boolean mustAble;
	
	/**是否多选*/
	private Boolean multiAble;
	
	/***/
	private Boolean specAble;
	
	private Boolean searchAble;
	
	private Boolean colorAble;
	
	private Type type;
	
	public enum Type {
		text,image
	}
	
	@OneToMany(fetch=FetchType.LAZY,mappedBy="property",cascade={CascadeType.REFRESH,CascadeType.PERSIST,CascadeType.REMOVE,CascadeType.MERGE})
	private Set<PropertyValue> values = new HashSet<>();
	
	@ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.MERGE,CascadeType.REFRESH})
	private Category category;
	
	@ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.MERGE,CascadeType.REFRESH})
	private PropertyGroup propertyGroup;
	

}
